package form

import (
	"github.com/kordar/gormext"
	"labelsys/dataset/model"
)

type DatasetForm struct {
	ID          gormext.StrInt   `json:"id"`
	Name        string           `json:"name" binding:"required"`
	Description string           `json:"description"`
	State       gormext.StrInt   `json:"state"`
	Type        string           `json:"type"`
	Scene       string           `json:"scene"`
	Sort        gormext.StrInt   `json:"sort"`
	BucketID    gormext.StrInt64 `json:"bucket_id"`
}

func (s DatasetForm) Target() interface{} {
	return &model.LabelsysDataset{
		ID:          int64(s.ID),
		Name:        s.Name,
		State:       int32(s.State),
		Type:        s.Type,
		Description: s.Description,
		Scene:       s.Scene,
		Sort:        int32(s.Sort),
		BucketID:    int64(s.BucketID),
	}
}

type DatasetLabelForm struct {
	ID        gormext.StrInt   `json:"id"`
	Name      string           `json:"name" binding:"required"`
	Remark    string           `json:"remark"`
	Color     string           `json:"color"`
	DatasetID gormext.StrInt64 `json:"dataset_id" binding:"required"`
	Thumb     string           `json:"thumb"`
	Filename  string           `json:"filename"`
}

func (s DatasetLabelForm) Target() interface{} {
	return &model.LabelsysDatasetLabel{
		ID:        int64(s.ID),
		Name:      s.Name,
		Remark:    s.Remark,
		Color:     s.Color,
		DatasetID: int64(s.DatasetID),
		Thumb:     s.Thumb,
		Filename:  s.Filename,
	}
}

type UploadForm struct {
	BucketID  gormext.StrInt64 `json:"bucket_id"  form:"bucket_id" binding:"required"`
	DatasetID gormext.StrInt64 `json:"dataset_id"  form:"dataset_id" binding:"required"`
	Type      string           `json:"type"  form:"type" binding:"required"`
	Path      string           `json:"path"  form:"path"`
	FileName  string           `json:"filename"  form:"filename"` // 文件名称
	Position  int              `json:"position"  form:"position"`
}
